import request from '@/config/axios'

// 阶段-评委设置 VO
export interface StageJudgeVO {
  id: string // 阶段评委设置ID
  mentorId: number // 导师ID
  awardsId: string // 评奖ID
  instanceRuleId: string // 评奖阶段规则设置ID
  isSubmit: boolean // 是否提交结果
  isConfirmResult: boolean // 是否确认最终获奖结果
  isGroupJudge: boolean // 是否是专业分组评委
  groupId: string // 阶段-专业分组ID
  remark: string // 备注
}

// 管理后台 - 阶段-评委已选列表 Response VO
export interface StageJudgeSelectedRespVO {
  id: string // 主键
  mentorId: number // 导师ID
  awardsId: string // 评奖ID
  instanceRuleId: string // 评奖阶段规则设置ID
  groupId: string // 专业分组ID
  nickname: string // 教师姓名
  jobCode: string // 工号
  mobile: string // 手机号码
  deptName: string // 部门名称
  zcm: string // 职称码
  workingStatus: number // 工作状态，参见 WorkingStatusEnum 枚举类
}

// 阶段-评委设置 API
export const StageJudgeApi = {
  // 查询阶段-评委设置分页
  getStageJudgePage: async (params: any) => {
    return await request.get({ url: `/awards/stage-judge/page`, params })
  },

  // 查询阶段-评委设置详情
  getStageJudge: async (id: string) => {
    return await request.get({ url: `/awards/stage-judge/get?id=` + id })
  },

  // 新增阶段-评委设置
  createStageJudge: async (data: StageJudgeVO) => {
    return await request.post({ url: `/awards/stage-judge/create`, data })
  },

  // 修改阶段-评委设置
  updateStageJudge: async (data: StageJudgeVO) => {
    return await request.put({ url: `/awards/stage-judge/update`, data })
  },

  // 删除阶段-评委设置
  deleteStageJudge: async (id: string) => {
    return await request.delete({ url: `/awards/stage-judge/delete?id=` + id })
  },

  // 导出阶段-评委设置 Excel
  exportStageJudge: async (params) => {
    return await request.download({ url: `/awards/stage-judge/export-excel`, params })
  },

  // 查询指定ruleId中 非groupId的评委
  getConflictMajorJudge: async (ruleId: string, groupId: string) => {
    return await request.get({
      url: `/awards/stage-judge/conflict-judge?ruleId=${ruleId}&groupId=${groupId}`
    })
  },

  // 批量创建阶段-评委
  createStageJudgeBatch: async (
    ruleId: string,
    groupId: string | undefined,
    data: Partial<StageJudgeVO>[]
  ) => {
    const group = groupId ? `?groupId=${groupId}` : ''
    return await request.post({
      url: `/awards/stage-judge/create-batch/${ruleId}${group}`,
      data
    })
  },

  // 批量删除阶段-评委
  deleteStageJudgeBatch: async (
    ruleId: string,
    groupId: string | undefined,
    data: Partial<StageJudgeVO>[]
  ) => {
    const group = groupId ? `?groupId=${groupId}` : ''
    return await request.delete({
      url: `/awards/stage-judge/delete-batch/${ruleId}${group}`,
      data
    })
  }
}
